/*******************************************************************************
 * ***** BEGIN LICENSE BLOCK *****
 *
 * This file is part of CCValidator.
 * Copyright 2009 Corlatti (http://www.corlatti.com.ar/)
 *
 * CCValidator is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * CCValidator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ***** END LICENSE BLOCK *****
 *
 * $Id: CCValidatorUtil.js 15 2009-03-28 23:10:30Z corlatti $
 * 
 * This file contains misc utils
 * 
 *******************************************************************************/
/* utils */
String.prototype.trim = function(){
	return this.replace(/^\s+|\s+$/g,"");;
}
String.prototype.isIn = function(arr){
	var result = false;
	try {
		for(var i=0; i<arr.length; i++){
			if(arr[i].toLowerCase().trim() == this.toLowerCase().trim()){
				result = true;
				break;
			}
		}
	} catch(e){
		throw e;
	}
	return result;
}
String.prototype.capitalize = function(){
	var result = this;
	try {
		result = this.substring(0,1).toUpperCase() + this.substring(1, this.length);
	} catch(e){
		throw e;
	}
	return result;
}

//el replace solo reemplaza una vez, se corrige con un while
String.prototype.replaceAll = function(cha, replacement){
	var result = this;
	try {
		var tmp = result;
		while(tmp.indexOf(cha) != -1){
			tmp = tmp.replace(cha, replacement);
		}
		result = tmp;
	} catch(e){
		throw e;
	}
	return result;
}




